package com.qyhl.module_practice.newhome.code;


import com.qyhl.module_practice.common.PracticeUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.civilized.PracticeVolunteerDetailBean;

public class PracticeQRCodeModel implements PracticeQRCodeContract.PracticeQRCodeModel {
    private PracticeQRCodePresenter mPresenter;

    PracticeQRCodeModel(PracticeQRCodePresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(String volId) {

        EasyHttp.get(PracticeUrl.GET_PRACTICE_VOLUNTEER_DETAIL)
                .params("volId", volId)
                .execute(new SimpleCallBack<PracticeVolunteerDetailBean>() {
                    @Override
                    public void onError(ApiException e) {
                        if (e.getCode() == 202) {
                            mPresenter.setError("暂无任何内容！");
                        } else {
                            mPresenter.setError("请求出错，请稍后再试！");
                        }
                    }

                    @Override
                    public void onSuccess(PracticeVolunteerDetailBean practiceVolunteerDetailBean) {
                        mPresenter.setDetail(practiceVolunteerDetailBean);
                    }
                });
    }
}
